<?php 
	function addCategory($array){
		$query = 'INSERT INTO category (category_name, category_description) VALUES ';
		$values = '';
		foreach($array as $v){
				$values = $values."('".$v['cname']."', '".$v['cdesc']."'), ";	
		}
		$values = substr_replace($values, '', -2);
		$query = $query.$values;
		$r = mysql_query($query) or die('Error: '.mysql_error());
		return $r >= 1 ? TRUE : 0;
	}
	
	function getCategories(){
		$query = 'SELECT * FROM category';
		$r = mysql_query($query) or die('Error: '.mysql_error());
		$results = array();
		if(mysql_num_rows($r) >= 1){
			while($row = mysql_fetch_array($r, MYSQL_ASSOC)){
				$results[] = $row;	
			}
			return $results;
		}
		else
			return 0;
	}
?>